package com.eshop.modules.user.service.impl;

import com.eshop.common.service.impl.*;
import com.eshop.modules.user.service.mapper.*;
import com.eshop.modules.user.domain.*;
import com.eshop.modules.user.service.*;
import org.springframework.stereotype.*;
import org.springframework.transaction.annotation.*;
import com.baomidou.mybatisplus.extension.conditions.query.*;
import java.lang.invoke.*;
import org.slf4j.*;

@Service
@Transactional(rollbackFor = { Exception.class })
public class UserTaskFinishServiceImpl extends BaseServiceImpl<UserTaskFinishMapper, UserTaskFinish> implements UserTaskFinishService
{
    private static final Logger log;
    private final UserTaskFinishMapper userTaskFinishMapper;
    
    public void setFinish(final Long uid, final int taskId) {
        final int count = ((this.lambdaQuery().eq(UserTaskFinish::getUid, uid)).eq(UserTaskFinish::getTaskId, taskId)).count();
        if (count == 0) {
            final UserTaskFinish userTaskFinish = new UserTaskFinish();
            userTaskFinish.setUid(uid);
            userTaskFinish.setTaskId(taskId);
            this.userTaskFinishMapper.insert(userTaskFinish);
        }
    }
    
    public UserTaskFinishServiceImpl(final UserTaskFinishMapper userTaskFinishMapper) {
        this.userTaskFinishMapper = userTaskFinishMapper;
    }
    
    static {
        log = LoggerFactory.getLogger((Class)UserTaskFinishServiceImpl.class);
    }
}
